<% i = 0 %>
<div class="product_table">
  <% products.each do |product| %>
    <% if i % 3 == 0 %>
      <div class="product_row">
    <% end %>
    <div class="product_cell">
        <% if product.image.exists? then %>
            <div style="text-align: center; min-height: 120px">
                <%= image_tag product.image.url(:thumb) %>
            </div>
        <% end %>
        <h3 style="margin: 0; overflow: hidden">
            <%= link_to product.name, product %>
        </h3>
        <%= render 'products/admin_buttons', :product => product %>

        <p style="font-weight: bold; margin: 0"><%= "#{t("product.price")}: #{number_to_currency(product.price)}" %></p>

        <div style="margin: 0" class="product_item">
            <%= link_to t("product.show.link"), product, :class => "button" %>
            <%= link_to t("cart.model_name"), {:controller => "carts", :action => "add",
                              :id => product},
                        :method => :post,
                        :remote => true,
                        :class => "button" %>
        </div>
    </div>
    <% if i % 3 == 2 || i == (products.length - 1) %>
      </div>
    <% end %>
    <% i = i+1 %>
  <% end %>
</div>
